import { ILeaderboardItem } from "../../model/model-account";

const { ccclass, property, menu } = cc._decorator;

@ccclass
@menu('wnds/LeaderboardItemComp')
export default class LeaderboardItemComp extends cc.Component {

    @property(cc.Sprite)
    backSpr: cc.Sprite = null;

    @property(cc.Label)
    rankLbl: cc.Label = null;

    @property(cc.Sprite)
    iconSpr: cc.Sprite = null;

    @property(cc.Label)
    nameLbl: cc.Label = null;

    @property(cc.Label)
    scoreLbl: cc.Label = null;

    @property([cc.SpriteFrame])
    backSprList: cc.SpriteFrame[] = [];


    initUI(res: ILeaderboardItem) {
        this.updateUI(res);
    }

    updateUI(res: ILeaderboardItem) {
        this.rankLbl.string = res.rank + '';
        // this.iconSpr.spriteFrame = 
        this.nameLbl.string = res.name;
        this.scoreLbl.string = res.hearts + '';
        this.backSpr.spriteFrame = this.backSprList[1 - res.isMe];
    }
}
